//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
/// @file
///
///
/// 
/// @author Davide Pasca
/// 
//==================================================================

#ifndef RENDDEVICESTATE_H
#define RENDDEVICESTATE_H

#include "psys.h"
#include "psys_stdgfx.h"
#include "texture_base.h"

//==================================================================
///
//==================================================================
class RendDevice;

//==================================================================
///
//==================================================================
struct RendDeviceState
{
	RendDevice				*_devicep;
	bool					_zwrite;
	bool					_ztest;

	bool					_blend;
	PSYSGFX::BlendFactor	_blend_src;
	PSYSGFX::BlendFactor	_blend_dst;

	bool					_alphatst;
	PSYSGFX::TestFunc		_alphatst_func;
	float					_alphatst_ref;

	PSYSGFX::Culling		_culling;
	TextureBase				*_texturep;

	int						_viewport_xywh[4];
	float					_viewport_minmaxz[2];

public:
	RendDeviceState( RendDevice *devicep ) :
		_devicep(devicep)
	{
	}

	void Reset();

	void SetZWrite( bool onoff );
	void SetZTest( bool onoff );
	void SetBlending( bool onoff );
	void SetBlending( bool onoff, PSYSGFX::BlendFactor src, PSYSGFX::BlendFactor dst );
	void SetAlphaTest( bool onoff, PSYSGFX::TestFunc tstfunc, float refparam );
	void SetAlphaTest( bool onoff );
	void SetCulling( PSYSGFX::Culling culling );
	void SetTexture( TextureBase *texturep );
	void SetTextureFilter( int tex_idx, PSYSGFX::TexFilterType type, PSYSGFX::TexFilterMode mode );
	void SetTextureCoordAddr( int tex_idx, PSYSGFX::TexAddrType type, PSYSGFX::TexAddrMode mode );

	void SetViewport( int x, int y, int w, int h, float min_z=0, float max_z=1 );
};

#endif
